<?php
if(!defined('ROOTPATH')) exit('No Define ROOTPATH');


class WooQuery
{
    /**
     * 查询SQL语句预结构，由数组构成，方便组合为SQL字符串
     * @var array
     */
    private $_sqlBuild;

    public function __construct()
    {
    }

    /**
     * 初始化数据表对象
     * @param object $map
     * @param string $beAs
     * @return object
     */
    public function table($map, $beAs = NULL)
    {
        $this->map = new datamap($map);
        $this->_sqlArray = array(
            'select' => array(),
            'from' => '',
            'where' => array(),
            'join' => array(),
            'group' => array(),
            'order' => array(),
            'limit' => '',
            'offset' => ''
        );
    }

    /**
     * Select field
     * @param string $field
     * @param string $beAs
     * @return object
     */
    public function select($field, $beAs = NULL)
    {
    }
}

$query = new WooQuery();
$art = $query->table('article', 'a')
    ->where('art_id', '738')
    ->where('title', '%hello%', 'like');
$cat = $query->table('category', 'c')
    ->where('cat_id', '1,2,3,4,5,8', 'in');
$art->leftJoin($cat, 'cat_id');
$result = $db->fetchAll($art->toSql());
